package goover.unit03;

import java.util.ArrayList;
import java.util.Iterator;

public class CollectionDemo01 {
    public static void main(String[] args){
        ArrayList<String> als = new ArrayList<>();
        ArrayList<String> als2 = new ArrayList<>();
        als.add("stu1");
        als.add("stu2");
        als.add("stu3");
        als.add("stu4");
        als.add("stu5");
        Iterator<String> iterator = als.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("------------------------");
        als.remove("stu1");
        als.add(0,"stu1");
        System.out.println(als.contains("stu1"));
        System.out.println(als2.contains(als));
        System.out.println(als);
        als2.addAll(als);
        als2.clear();
        System.out.println(als2.size());
        als2.addAll(0,als);
        als2.remove(0);
        als2.set(0,"stu0");
        System.out.println(als2.indexOf("stu3"));
        System.out.println(als2.lastIndexOf("stu3"));
        System.out.println(als2);
        Object[] ob = als2.toArray();
        for (Object o:ob) {
            System.out.println(o);
        }
        System.out.println(als2.subList(3,4));
    }
}
